<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.io.*, java.sql.*, java.util.*,LS.*, date.*"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
	Users u = (Users) session.getAttribute("user");
	// 	String p = u.getUser_position();
%>
<!DOCTYPE html>
<html lang="UTF-8">
<style>
th,td {
	padding-bottom: 5px;
	padding-top: 5px;
}

#title {
	font: 17px;
	font-weight: bold;
	text-align: right;
	width: 90px;
}

#result {
	text-align: left;
}

#content {
	text-align: left;
}

#title,#content {
	
}

.txta {
	width: 90%;
	height: 100%;
}

#content {
	
}

b.text {
	font-size: 25px;
	margin-bottom: 10px;
}

h4,h1 {
	margin: 0px;
	padding: 0px;
}

th {
	height: 30px;
	border-right: 1px solid #e5e5e5;
	border-bottom: 1px solid #e5e5e5;
}

tr {
	border-bottom: 1px solid #e5e5e5;
}

table {
	width: 100%;
}

.explain {
	color: red;
	font-size: 11px;
	border-bottom: 2px;
}

#outerview {
	padding-top: 10px;
	margin-left: 0px;
	text-align: center;
	background-color: #fff;
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

#outerview {
	width: 100%;
	min-height: 600px;
	padding: 0px;
}

#middleview {
	width: 90%;
	height: 450px;
	margin: 20px auto 0px auto;
	left: 50%;
}

#innerview {
	width: 100%;
	height: 100%;
	text-align: center;
	background-color: #fff;
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

#innerviewleft,#innerviewright {
	margin-left: 0px;
	padding-left: 0px;
}

#plusview {
	margin: 10px;
	margin-bottom: 0px;
	text-align: left;
}

.tableview {
	width: 100%;
	max-height: 100%;
	left: 50%;
}

.lendingdate {
	width: 20%;
}

.notify {
	width: 10%;
}
</style>

<head>
	<meta charset="utf-8">
	<title>성공회대학교 기자재 대여 시스템</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<!-- styles시트 -->
	<link href="assets/css/bootstrap.css" rel="stylesheet">
	<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
	<link href="assets/css/docs.css" rel="stylesheet">
	
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
	<script type="text/javascript">
		function beforeSubmit() {
			
		
			
			if($("#loss_and_damage_reason").val().trim() == "") {
				alert("신청사유를 입력하세요.")
			}
			else if($("#isNotified").val() == "true") {
				alert("이미 손망실 신고된 기자재 입니다.");
			}
			else if(confirm("해당 기자재의 손망실 신고를 하시겠습니까?")) {
				$("#frm1").submit();
			}
		}
	</script>
</head>

<body data-spy="scroll" data-target=".bs-docs-sidebar">
	<!-- 메뉴
    ================================================== -->
	<%
		if (session.getAttribute("user") == null) {
	%>
	<jsp:include page="/top.do"></jsp:include>
	<%
		} else {

			if (u.getUser_position().equalsIgnoreCase("S")) {
	%>
	<!-- 학생이 로그인 했을 경우 메뉴 -->
	<jsp:include page="/studenttop.do"></jsp:include>
	<%
		} else if (u.getUser_position().equalsIgnoreCase("P")) {
	%>
	<!-- 교수가 로그인 했을 경우 메뉴 -->
	<jsp:include page="/teachertop.do"></jsp:include>
	<%
		} else {
	%>
	<!-- 관리자가 로그인 했을 경우 메뉴 -->
	<jsp:include page="/managertop.do"></jsp:include>
	<%
		}
		}
	%>

	<!-- 게시판
    ================================================== -->

	<div style="text-align: center">
		<div class="marketing"
			style="margin-bottom: 30px; color: #000; text-align: left">
			<div class="container">
				<h3 style="margin: 10px; font-size: 35px;">
					<strong>손망실 신고</strong>
				</h3>
			</div>
		</div>
	</div>
	<div class="container">
		<div id="outerview">
			<div id="middleview">
				<div id="plusview">
					<form method="post">
						<b class="text">분실 기자재 선택</b>&nbsp;&nbsp;
						
						<!-- 컨트롤러에서 id로 모델 이름을 가져와서 리스트 박스에 배열 -->
						<select name="modelName" style="width: 200px;">
							<c:forEach var="equipments" items="${selectModelNameByUserId}">
								<option>${equipments.model_name}</option>
							</c:forEach>
						</select>
						<input class="btn" type="submit" style="margin-bottom:10px;" value="선택완료">
					</form>
				</div>
				<div id="innerview">
					<div id="innerviewleft" class="span6">
						
						<% 
						String modelName = request.getParameter("modelName");
						
						/* 로그인이 되어있고 대여한 모델이 존재할경우에만 게시판을 웹에 출력. */
						if(u != null && modelName != null) {
						%>
						<form id="frm1" action="notifyBtn.do" method="post">
						
						<br>
						<div id="title" class="span2">분류</div>
						<div id="content" class="span2">
						<select name="loss_and_damage_state" style="width: 100px;">
							<option>손상</option>
							<option>분실</option>
						</select>
						</div>
						<br><br>
						<div id="title" class="span2">소속학과</div>
						<div id="content" class="span2">
							<c:forEach var="d" items="${ departments }">
								${d.departments_name}<br>
							</c:forEach>
						</div><br><br>
						
						<div id="title" class="span2">학번</div><div id="content" class="span2"><%= u.getUser_id() %></div><br><br>
						<div id="title" class="span2">학년</div><div id="content" class="span2"><%= u.getGrade() %></div><br><br>
						<div id="title" class="span2">이름</div><div id="content" class="span2"><%= u.getName() %></div><br><br>
						<div id="title" class="span2">연락처</div><div id="content" class="span2"><%= u.getPhone() %></div><br><br>
						<div id="title" class="span2">품목명</div><div id="content" class="span2">${ selectVwIELUByUserIdModelName.item_name }</div><br><br>
						<div id="title" class="span2">모델명</div><div id="content" class="span2">${ selectVwIELUByUserIdModelName.model_name }</div><br><br>
						<div id="title" class="span2">대여일</div><div id="content" class="span2"><fmt:formatDate pattern="yyyy년 MM월 dd일" value="${ selectVwIELUByUserIdModelName.lending_start_date }" />
						</div><br><br>
						<div id="title" class="span2">신청일자</div><div id="content" class="span2"><fmt:formatDate pattern="yyyy년 MM월 dd일" value="${ selectVwIELUByUserIdModelName.apply_date }" />
						</div><br><br>
						<div id="title" class="span2">신청사유</div><div id="content" class="span4"><textarea name="loss_and_damage_reason" class="txta" id="loss_and_damage_reason"></textarea></div>
						
						<input type="hidden" name="lending_id" value="${ selectVwIELUByUserIdModelName.lending_id }">
						
						<% boolean isNotified = false; %>
						<c:forEach var="l_id" items="${ selectLendingIdFromLD }">
							<c:if test="${ selectVwIELUByUserIdModelName.lending_id == l_id.lending_id }">
								<% isNotified = true; %>
							</c:if>
						</c:forEach>
						<input type="hidden" id="isNotified" value="<%=isNotified%>">
						</form>
					</div>
					
					<!-- 관리자가 로그인 했을 경우 메뉴 -->
					<%
							if (u.getUser_position().equalsIgnoreCase("M")) {
					%>
					
					<div id="innerviewright" class="span5">

						<div id="result">
							<br> <b>처리 과정</b><br>
							<br>
							<form method="post">
								<label class="radio"> <input type="radio" name="r"
									value="">현금 배상&nbsp;&nbsp;&nbsp;
								</label> <label class="radio"> <input type="radio" name="r"
									value="">대체품 배상
								</label> <br>
								<textarea rows="10" style="width: 90%"></textarea>
								<div style="text-align: right; padding-right: 30px;">
									<button type="submit" class="btn">처리과정 저장</button>
									<button type="submit" class="btn">처리 완료</button>
								</div>
							</form>
						</div>
					</div>
					<%}%>
					
				</div>
				
				<div style="text-align: right;">
					<Button onclick="beforeSubmit()" class="btn">신고 완료</Button>
				</div>
				<%}%>
			</div>
		</div>
	</div>



		<script type="text/javascript">
		<%-- 
		if(<%=request.getParameter("abc")%> != null) {
			alert("1" + <%=request.getParameter("abc")%>);
		}
		else {
			alert("2" + <%=request.getParameter("abc")%>);
		}
		 --%>
		
		<%-- 
			if(<%=request.getParameter("msg")%> != null) {
				alert(<%=request.getParameter("msg")%>)
			} else {
				alert(<%=request.getParameter("msg")%>)
			}
		 --%>
		</script>

	<!-- 꼬리말
    ================================================== -->
	<footer class="footer">
		<div class="container">
			<p>Copyright SKHU. Software Student.</p>
		</div>
	</footer>


	<!-- javascript -->
	<script src="assets/js/jquery.js"></script>
	<script type="text/javascript" src="assets/js/bootstrap.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$('.dropdown-toggle').dropdown();
		});
	</script>
</body>
</html>
